#!/bin/sh -
# -*- coding: utf-8 -*-

import re
class filter:
	def __init__(self):
		self.filters = self.getFilters()

	def getFilters(self):
		fi = open("regs.txt")
		filerts = []
		try:
			for line in fi:
				reg = line.strip()
				if(reg.find('block:')==0):
					reg = reg[7:-2]
					#print reg
					filerts.append(re.compile(reg,re.I))
		finally:
			fi.close()
			return filerts
	def check(self,url):
		result = 'pass'
		p = '    '
		for filert in self.filters:
			if(url.find('tongji.linezing.com/1228858/')>0):
				break
			if(filert.search(url)):
				result ='block'
				p = 'b   '
				break
		print p,url
		return result
	def update(self):
		self.filters = self.getFilters()
if __name__ == '__main__':
	print filter().filters